<?php


namespace Home\Controller;

use Think\Controller;
use User\Api\UserApi;

// 指定允许其他域名访问  
header('Access-Control-Allow-Origin:*');  
// 响应类型  
header('Access-Control-Allow-Methods:*');  
// 响应头设置  
header('Access-Control-Allow-Headers:x-requested-with,content-type');   

class UserController extends Controller
{
    
    //注册
    public function register()
    {   
        if(!IS_POST)
        {
            datamsg(0,'非法操作');
        }
        $rules = array(
             array('tel','require','手机号必须！',1),
             array('verify','require','验证码必须！',1), //默认情况下用正则进行验证
             array('password','require','密码必须！',1),
             array('repassword','require','确认密码必须！',1),
             array('tel','','手机号已经存在！',0,'unique',1), // 在新增的时候验证name字段是否唯一
             array('repassword','password','确认密码不正确',0,'confirm',1) // 验证确认密码是否和密码一致
        );

        $password=I('password');
        if(!preg_match("/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/",$password)){
            datamsg(0,"密码必须包含数字和字母,密码长度不得低于8位");
        }

        $wxuser = M("wxuser"); 
        if (!$wxuser->validate($rules)->create()){
            datamsg(0,$wxuser->getError());
        }
        $mobile=I('tel');
        $verify=I('verify');


        $res= D("verify")->where("mobile=".$mobile)->order("id desc")->find();

        if ($res['random']!=$verify) {
            datamsg(0,'验证码输入错误！');
        }
        $time=$res['create_time']+180;

        if($time<time()){
            datamsg(0,'验证码已过期');
        }
        $User = new UserApi;
        $uid = $User->register($mobile,$password);

        if($uid<0)
        {
            datamsg(0,$this->showRegError($uid));
        }
        $pho['mobiele']=$mobile;
        datamsg('1','注册成功',$pho);


    }
    
    //所有用户数据
    public function plan()
    {   
    	!IS_POST && datamsg(0,'非法操作');
        $user=user_cinfo(I('post.user_id'),I('post.token'));
        $result=D('siji')->field('status')->where('openid="'.$user['openid'].'"')->find();
        $result=$result['status'];
        if($result==null)
        {
            $result=3;
            datamsg(1,'成功',$result);
        }
        if($result==0)
        {
            $result='0';
            datamsg(1,'成功',$result);
        }
        datamsg(1,'成功',$result);
    }

    //用户余额
    public function money_user()
    {   
        !IS_POST && datamsg(0,'非法操作');
        $user=user_cinfo(I('post.user_id'),I('post.token'));

        $endToday=getWeek2($user);
        
        $user['money_x'] = $endToday['zongshouru'];
        $user['price'] = $endToday['ketixian'];

        datamsg(1,'成功',$user);
    }

    //所有用户数据
    public function user_list()
    {
    	!IS_POST && datamsg(0,'非法操作');
        $user_id=I('user_id');
        if(empty($user_id))
        {
            datamsg(0,'错误');
        }
        $res=D('wxuser')->where('uid='.$user_id)->find();
        if(empty($res))
        {
            datamsg(0,'错误');
        }
        
        $result=D('wxuser')->field('uid,nickname,password,token')->select();
        datamsg(1,'成功',$result);
    }

    //所有认证过的用户数据
    public function user_list1()
    {
    	!IS_POST && datamsg(0,'非法操作');
    	$user_id=I('user_id');
        if(empty($user_id))
        {
            datamsg(0,'错误');
        }
        $res=D('wxuser')->where('uid='.$user_id)->find();
        if(empty($res))
        {
            datamsg(0,'错误');
        }
        $result=D('wxuser as a')->field('a.uid,a.nickname,a.password,a.token,b.status')->join('hy_siji as b on a.openid=b.openid')->where('b.status=1')->select();

        datamsg(1,'成功',$result);
    }

    //账户状态
    public function status_user()
    {
    	!IS_POST && datamsg(0,'非法操作');
        $user_id=I("user_id");
        $token=I("token");
        $user=user_cinfo($user_id,$token);
        datamsg('1','成功',$user);
    }

    //验证码登录
    public function login_code()
    {
    	!IS_POST && datamsg(0,'非法操作');
        $mobile=I('tel');
        $code=I('code');

        $rules = array(
             array('tel','require','手机号必须！',1),
             array('tel','/^1[345678]{1}\d{9}$/','请输入正确的手机号码！','0','regex',1),
             array('code','require','密码必须！',1),
        );
        $wxuser = M("wxuser"); 
        if (!$wxuser->validate($rules)->create()){
            datamsg(0,$wxuser->getError());
        }

        $res=D('verify')->where('mobile='.$mobile.' and random='.$code)->find();
        empty($res) && datamsg(0,'验证码输入错误！');
        $time=$res['create_time']+180;
        $time<time() && datamsg(0,'验证码已过期');
      	
      	$uid=D('wxuser')->where('tel='.$mobile)->getField('uid');
      	empty($uid) && datamsg(0,'用户不存在');
        /* 登录用户 */
        $Member = D('Wxuser');
        if ($result = $Member->login($uid)) { //登录用户
           $data=$_SESSION['user_auth'];
           unset($data['last_login_time']);
           datamsg('1','登录成功',$data);

        } else {
        	datamsg(0,$Member->getError());
        }
    }

    //登录
      public function login()
    {
    	!IS_POST && datamsg(0,'非法操作');
        $mobile=I("tel");
        $password=I("password");
        $rules = array(
             array('tel','require','手机号必须！',1),
             array('password','require','密码必须！',1),
        );
        $wxuser = M("wxuser");
        if (!$wxuser->validate($rules)->create()){
            datamsg(0,$wxuser->getError());
        }
        /* 调用UC登录接口登录 */
        $user = new UserApi;
        $uid = $user->login_qian($mobile,$password);
        if (0 < $uid) { //UC登录成功
            /* 登录用户 */
            $Member = D('Wxuser');
           	// unset($_SESSION[''])
            if ($result = $Member->login($uid)) { //登录用户
                // $urls=$_SERVER['SERVER_NAME'];
               $data=$_SESSION['user_auth'];
               unset($data['last_login_time']);
               datamsg('1','登录成功',$data);
            } else {
            	datamsg(0,$Member->getError());
            }
        } else { //登录失败
            switch ($uid) {
                case -1:
                    $error = '用户不存在！';
                    break; //系统级别禁用
                case -2:
                    $error = '密码错误！';
                    break;
                default:
                    $error = '未知错误！';
                    break; // 0-接口参数错误（调试阶段使用）
            }
            datamsg(0,$error);
        }
    }


    public function logout(){
        if(is_login()){
            $data['uid']=I('post.uid');
            empty($data) && datamsg(0,'数据非法');
            if(session('user_auth.uid')==$data['uid'])
            {
                D('wxuser')->logout();
                datamsg(1,'退出成功');
            }else
            {
                datamsg(0,'还未登录');
            };

            
        } else {
            datamsg(0,'还未登录');
        }
    }



     //忘记密码
     public function wj_pwd(){

        if(!IS_POST)
        {
           datamsg(0,'非法操作');
        }

        $mobile=I("tel");
        $verify=I("verify");
        $res['password']=I("newpassword");
        $password['password']=I("newpassword");

        $rules = array(
             array('tel','require','手机号必须！',1),
             array('verify','require','验证码必须！',1),
             array('newpassword','require','新密码必须！',1),
        );
         if(!preg_match("/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/",$password['password'])){
             datamsg(0,"密码必须包含数字和字母,密码长度不得低于8位");
         }
        $wxuser = M("wxuser"); 
        if (!$wxuser->validate($rules)->create()){
            datamsg(0,$wxuser->getError());
        }

        $res= D("verify")->where("mobile=".$mobile)->order("id desc")->find();
       
        if ($res['random']!=$verify) {
            datamsg(0,'验证码输入错误！');
        }
        $time=$res['create_time']+180;
        if($time<time())
        {
            datamsg(0,'验证码已过期');
        }

        $user=D("wxuser")->where("tel=".$mobile)->find();


        $Api = new UserApi();
        $status = $Api->updateInfo_wj($user['uid'],$password);
      
        if($status['status']=="")
        {
           datamsg(0,$status['info']);
        }
        datamsg(1,'修改成功');
       
    }

    //个人信息
    public function user_info()
    {
    	if(!IS_POST)
    	{
    		datamsg(0,'非法操作');
    	}
    	$user_id=I('user_id');
    	$token=I('token');


    	$rules = array(
             array('user_id','require','请先登录！',1),
             array('token','require','请先登录！',1)
        );

        $wxuser = M("wxuser"); 
        if (!$wxuser->validate($rules)->create()){
            datamsg(0,$wxuser->getError());
        }

        $user=D("wxuser")->field('uid,tel,openid')->where("uid=".$user_id." and token='".$token."'")->find();
        if(empty($user))
        {
            datamsg(0,'该用户不存在');
        }
        $res= D('siji')->field('city,xingming,card_sf,create_jztime,card_code')->where('openid="'.$user['openid'].'"')->find();
        $res['tel']=$user['tel'];
        datamsg('1',"成功",$res);
    }


     public function get_base64_img($base64,$path = 'Uploads/sign/'){
        if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64, $result)){
              
            $type = $result[2];
            $co=rand('1','20');
     
            $new_file = $path.md5(time().$co).".{$type}";

            if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64)))){
                return $new_file;
            }else{
                return  false;
            }
        }
    }


 	 // 车主注册
    public function chezhu_reg()
    {   
        if(!IS_POST)
        {
            datamsg(0,'非法操作');
        }
   
        $user_id=I("user_id");
        $token=I("token");

        $rules = array(
             array('user_id','require','请先登录！',1),
             array('token','require','请先登录！',1),
             array('city','require','请选择城市！',1),
             array('xingming','require','请填写姓名！',1),
             array('card_sf','require','请填写身份证号！',1),
             array('create_jztime','require','请填写初次领取驾照时间！',1),
             array('card_img','require','请上传身份证人头像！',1),
             array('card_gh','require','请上传身份证国徽像！',1),
             array('jiashi_img','require','请上传驾驶证图片！',1),
             array('jiashi_fm','require','请上传驾驶证反面图片！',1),
             array('xingshi_zm','require','请上传行驶证正面！',1),
             array('xingshi_fm','require','请上传行驶证反面！',1),
             array('xingshi_fb','require','请上传行驶证副本！',1),
             array('mancar_img','require','请上传人车合影！',1),
             array('card_code','require','请填写银行卡号！',1),
             );
       

        $wxuser = M("wxuser"); 
        if (!$wxuser->validate($rules)->create()){
            datamsg(0,$wxuser->getError());
        }
  
        $user=D("wxuser")->field('openid,uid,nickname,tel')->where("uid=".$user_id." and token='".$token."'")->find();
        if(empty($user)){
        	datamsg(0,'用户不存在或登录超时！');
        }
        $res=D('siji')->where("openid='".$user['openid']."'")->find();      //查找当前司机的信息
        $info=array(
            'city'=>I('city'),
            'xingming'=>I('xingming'),
            'dianhua'=>$user['tel'],
            'card_img'=>I("card_img"),
            'card_gh'=>I("card_gh"),
            'card_sf'=>I('card_sf'),
            'create_jztime'=>I('create_jztime'),
            'jiashi_img'=>I("jiashi_img"),
            'jiashi_fm'=>I("jiashi_fm"),
            'xingshi_zm'=>I("xingshi_zm"),
            'xingshi_fm'=>I("xingshi_fm"),
            'xingshi_fb'=>I("xingshi_fb"),
            'mancar_img'=>I("mancar_img"),
            'openid'=>$user['openid'],
            'status'=>0,
            'card_code' =>I('card_code'),
        );
        if($res){
            if($res['status'] == 0){
                datamsg(0,'对不起，您现在还不能提交，您的资料还在审核中');
            }elseif($res['status'] == 1){
                datamsg(0,'对不起，您已经提交过资料了');
            }
            $info = D('siji')->where(array('openid'=>$user['openid']))->save($info);
        }else{
            $info = D('siji')->add($info);
        }

        if(empty($info))
        {
        	datamsg(0,'系统繁忙，请稍后再试');
        }

        datamsg(1,'提交成功，请等待审核！');
            
    }
    //用户协议
    public function xieyi()
    {
        if(!IS_POST)
        {
            datamsg(0,"非法操作");
        }
        $id=empty(I('id'))?5:I('id');
        $info=D('article')->find($id);
//        $info['content']    = htmlspecialchars_decode($info['content']);
        if(empty($info))
        {
            datamsg('0','找不到该项目');
        }
        datamsg('1','成功',$info);
    }
    //修改手机号
     public function up_mobile()
    {
        if(!IS_POST)
        {
            datamsg(0,"非法操作");
        }

        $rules = array(
             array('tel','require','请填写手机号！',1),
             array('password','require','请填写密码！',1),
             array('newtel','require','请填写新手机号！',1),
             array('verify','require','请填写验证码！',1),
        );

        $wxuser = M("wxuser"); 
        if (!$wxuser->validate($rules)->create()){
            datamsg(0,$wxuser->getError());
        }
        $tel=I('tel');
        $mobile=I('newtel');
        $verify=I('verify');
        $password=I('password');

        $user = new UserApi;
        $uid = $user->login_qian($tel,$password);

        if (0 < $uid) { 
           
            $res= D("verify")->where("mobile=".$mobile)->order("id desc")->find();

            if (empty($res) || $res['random']!=$verify) {
                datamsg(0,'验证码输入错误！');
            }
            $time=$res['create_time']+180;
            if($time<time())
            {
                datamsg(0,'验证码已过期');
            }

            if(D("wxuser")->where("tel=".$mobile)->find())
            {
               datamsg(0,"新手机号已被注册！");
            }

            $ress['tel']=$mobile;
            $ress['openid']='wap_'.$mobile;


            $newuser=D("wxuser")->where("uid=".$uid)->save($ress);



            $siji   = D("siji")->where(array('openid'=>'wap_'.$tel))->find();
            if($siji){
                $resss['dianhua']=$mobile;
                $resss['openid']='wap_'.$mobile;
                D("siji")->where("id=".$siji['id'])->save($resss);
            }

            $basic_driver_information   = D("basic_driver_information")->where(array('openid'=>'wap_'.$tel))->find();
            if($basic_driver_information){
                $resss['openid']='wap_'.$mobile;
                D("basic_driver_information")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }

            $car_basic   = D("car_basic")->where(array('openid'=>'wap_'.$tel))->find();
            if($car_basic){
                $resss['openid']='wap_'.$mobile;
                D("car_basic")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }

            $car_locating_information   = D("car_locating_information")->where(array('openid'=>'wap_'.$tel))->find();
            if($car_locating_information){
                $resss['openid']='wap_'.$mobile;
                D("car_locating_information")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }

            $cheliang_info   = D("cheliang_info")->where(array('openid'=>'wap_'.$tel))->find();
            if($cheliang_info){
                $resss['openid']='wap_'.$mobile;
                D("cheliang_info")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }

            $czlog   = D("czlog")->where(array('openid'=>'wap_'.$tel))->find();
            if($czlog){
                $resss['openid']='wap_'.$mobile;
                D("czlog")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }

            $evaluate_comment   = D("evaluate_comment")->where(array('openid'=>'wap_'.$tel))->find();
            if($evaluate_comment){
                $resss['openid']='wap_'.$mobile;
                D("evaluate_comment")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }


            $getoutcar  = D("getoutcar")->where(array('openid'=>'wap_'.$tel))->find();
            if($getoutcar){
                $resss['openid']='wap_'.$mobile;
                D("getoutcar")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }


            $locating_information  = D("locating_information")->where(array('openid'=>'wap_'.$tel))->find();
            if($locating_information){
                $resss['openid']='wap_'.$mobile;
                D("locating_information")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }

            $paylog  = D("paylog")->where(array('openid'=>'wap_'.$tel))->find();
            if($paylog){
                $resss['openid']='wap_'.$mobile;
                D("paylog")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }

            $xllog  = D("xllog")->where(array('openid'=>'wap_'.$tel))->find();
            if($xllog){
                $resss['openid']='wap_'.$mobile;
                D("xllog")->where(array('openid'=>'wap_'.$tel))->save($resss);
            }



            if(!$newuser)
            {
                datamsg(0,'系统繁忙，请稍后再试');
            }

        } else { //登录失败
            switch ($uid) {
                case -1:
                    $error = '用户不存在！';
                    break; //系统级别禁用
                case -2:
                    $error = '密码错误！';
                    break;
                default:
                    $error = '未知错误！';
                    break; // 0-接口参数错误（调试阶段使用）
            }
            datamsg(0,$error);
        }
       

        datamsg(1,'修改成功');

    }
    //修改密码
    public function up_pwd()
    {
        if(!IS_POST)
        {
            datamsg(0,"非法操作");
        }
        $password=I("password");
        $res['password']=I("newpassword");
        
        $rules = array(
             array('user_id','require','请先登录！',1),
             array('token','require','请先登录！',1),
             array('password','require','请填写旧密码！',1),
             array('newpassword','require','请填写新密码！',1),
        );

        if(!preg_match("/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/",$password)){
            datamsg(0,"密码必须包含数字和字母,密码长度不得低于8位");
        }

        $wxuser = M("wxuser"); 
        if (!$wxuser->validate($rules)->create()){
            datamsg(0,$wxuser->getError());
        }

       
        $user_id=I("user_id");
        $token=I("token");
  
     	$user=user_cinfo($user_id,$token);
		
        $Api = new UserApi();
        $result = $Api->updateInfo($user_id, $password, $res);

  
        if($result['status']=="")
        {
           if($result['info']<0)
            {
                datamsg(0,$this->showRegError($result['info']));
            }
           datamsg(0,$result['info']);
        }
       datamsg(1,'修改成功');

    }


    //所有订单
    public function order_list()
    {
        if(!IS_POST)
        {
            datamsg(0,"非法操作");
        }
        $user_id=I('user_id');
        $token=I('token');

        $user=user_cinfo($user_id,$token);
        $list=D('xllog')->field('id,start,end,addtime,orderid,num,price,status,mobile,newpay')->where('openid="'.$user['openid'].'"')->order('id desc')->select();
        if(empty($list))
        {
        	datamsg('1','暂无更多');
        }
        foreach ($list as $k => $v) {
           $list[$k]['addtime']=date('Y-m-d H:i',$v['addtime']);
           $list[$k]['total_price']=$v['price']*$v['num'];
        }
        datamsg('1','成功',$list);
    }

    /**
     * 获取用户注册错误信息
     * @param  integer $code 错误编码
     * @return string        错误信息
     */
    private function showRegError($code = 0)
    {
        switch ($code) {
            case -1:
                $error = '用户名长度必须在16个字符以内！';
                break;
            case -2:
                $error = '用户名被禁止注册！';
                break;
            case -3:
                $error = '用户名被占用！';
                break;
            case -4:
                $error = '密码长度必须在6-30个字符之间！';
                break;
            case -5:
                $error = '邮箱格式不正确！';
                break;
            case -6:
                $error = '邮箱长度必须在1-32个字符之间！';
                break;
            case -7:
                $error = '邮箱被禁止注册！';
                break;
            case -8:
                $error = '邮箱被占用！';
                break;
            case -9:
                $error = '手机格式不正确！';
                break;
            case -10:
                $error = '手机被禁止注册！';
                break;
            case -11:
                $error = '手机号被占用！';
                break;
            default:
                $error = '未知错误';
        }
        return $error;
    }



    //验证手机号
    public function verifyphone(){

        $name = I("post.tel");
        $type = I("post.type");
        if(empty($name))
        {
            datamsg('0','请填写手机号！');
        }

       		$result_mobile=D('wxuser')->where('tel="'.$name.'"')->find();

       	if($type==1)
       	{
	        if(!empty($result_mobile))
	        {
	        	datamsg(0,'该手机号已经注册');
	        }
       	}elseif($type==2)
       	{
       		if(empty($result_mobile))
	        {
	        	datamsg(0,'该手机号还未注册');
	        }
       	}
        
        $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
        $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
        
        $count  = D('verify')->where('mobile='.$name.' and create_time>='.$beginToday.' and create_time<='.$endToday)->count('id');

        $count>=5 && datamsg(0,'今日短信接收量已超额');
       
       //  //调用发送短信方法
       // $this->phone($name);
        
        $statusStr = array(
        "0" => "短信发送成功",
        "-1" => "参数不全",
        "-2" => "服务器空间不支持,请确认支持curl或者fsocket，联系您的空间商解决或者更换空间！",
        "30" => "密码错误",
        "40" => "账号不存在",
        "41" => "余额不足",
        "42" => "帐户已过期",
        "43" => "IP地址限制",
        "50" => "内容含有敏感词"
        );
        $smsapi = "http://api.smsbao.com/";
        $user = "cbing"; //短信平台帐号
        $pass = md5("xyz98765"); //短信平台密码

        $random = $this->random(6,1);
        $data1['mobile']=$name;
        $data1['random']=$random;
        $data1['create_time']=time();
        
        $res= D("verify")->add($data1);

        $content="手机验证码：{$random}，3分钟内有效！【小易出行】";//要发送的短信内容
        $phone = $name;//要发送短信的手机号码
        $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
        $result =file_get_contents($sendurl) ;
        // echo $statusStr[$result];


        datamsg('1','发送成功');
    }

     /*
    * microtime() 函数返回当前 Unix 时间戳和微秒数。
    * mt_srand() 播种 Mersenne Twister 随机数生成器。从 PHP 4.2.0 版开始，seed 参数变为可选项，当该项为空时，会被设为随时数。
    * 注释：自 PHP 4.2.0 起，不再需要用 srand() 或 mt_srand() 函数给随机数发生器播种，现已自动完成。
    * pow — 指数表达式
    */
    //random()这个函数是我用来生成一个随机数的，
    //$numeric = 0生成一个6位的大小写字母与数字混合的字符串。$numeric = 1生成一个6位数字的字符串
     public function random($length = 6 , $numeric = 1) {
        PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
        if($numeric) {
            $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
        } else {
            $hash = '';
            $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghjkmnpqrstuvwxyz';
            $max = strlen($chars) - 1;
            for($i = 0; $i < $length; $i++) {
                $hash .= $chars[mt_rand(0, $max)];
            }
        }
        return $hash;
    }

    //发送短信的控制类为index
    public function phone($name){
        //以下三条读取配置文件中的内容即可
        $http ="http://api.sms.cn/mtutf8/";
        $uid = "ytech";
        $pwd = "xyz98765";
        //要接受信息的手机号码,这里只是一个用于测试的手机号，找个项目需求操作即可
        $mobile=$name;
        //生成随机码
        $random = $this->random(6,1);
        $data1['mobile']=$mobile;
        $data1['random']=$random;
        $data1['create_time']=time();

        //将值放入session 用于与输入的验证码进行验证
        session($mobile,$random);//消息编号，该参数用于发送短信收取状态报告用，格式为消息编号+逗号；与接收号码一一对应，可以重复出现多次。
        //这里只用一个编号即可，手机号加上微秒。
        $mobileids = intval($mobile).microtime();
        //要发送的内容
        $content = urlencode("欢迎您注册，手机验证码：{$random}，3分钟内有效！【小易出行】");
        //即时发送，即：操作后就会进行发送，以下有定时发送
        //调用封装好的短信接口类。
        $_SESSION["cc"]="cc";
        import('Test.Send');
        $send = new \Send();
        $res = $send->sendSMS($http,$uid,$pwd,$mobile,$content,$mobileids);
    }


//    /**
//     *@func 判断司机的审核状态
//     */
    public function checkstatus(){
        $user_id=I("post.user_id");
        $token=I("post.token");
        $user=user_cinfo($user_id,$token);
        if($user){
            $currentday = date('Y-m-d',time());
            $start_day = $currentday." 00:00:00";
            $end_day = $currentday." 23:59:59";
            $map['openid']=$user['openid'];
            $map['upcartime']=array("between",array(strtotime($start_day),strtotime($end_day)));
            $isexit = M('getoutcar')->where($map)->find(); //查看今天是否已经出车了
            if($isexit){
                $data['xcstatus']=$isexit['status'];
            }else{
                $data['xcstatus']=$isexit['status'];
            }
            $sijiarr = M('siji')->where(array('openid'=>$user['openid']))->field("status")->find();
            if($sijiarr){
                $data['status']=$sijiarr['status'];
            }else{
                $data['status']='';
            }
            datamsg(1,'获取成功',$data);
        }else{
            datamsg(0,'没有找到用户');
        }
    }


}
